package next.TemplateActivity;

import next.Admin.Admin_Principal;
import next.CommonProfile.Dashboard_Principal;
import next.CustomLayout.TitleBar;
import next.control.ApplicationController;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.widget.EditText;

public class NormalActivity extends Activity {

	// --Variables--
	protected String tag = new String("Events");
	protected Bundle b = new Bundle();
	protected TitleBar titleBar;
	protected Resources resources;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// Hides the title bar---
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.generic_normal_activity_layout);
		Log.d(tag, "In the onCreate() event");
	}

	// --Cycle life of
	// App-------------------------------------------------------
	/** Called when the activity start. */
	@Override
	public void onStart() {
		super.onStart();
		
		Log.d(tag, "In the onStart() event");
	}

	/** Called because of activity was STOPPED, and is now in foreground. */
	@Override
	public void onRestart() {
		//--Verify if the profile button was clicked
	 	super.onRestart();
	 	Log.d(tag, "In the onRestart() event");
	}

	/** Called because of activity was PAUSED, and is now in foreground. */
	@Override
	public void onResume() {
		super.onResume();
		if (ApplicationController.GOPROFILE){
	 		//--close the last Activity
	 		if ((this instanceof Admin_Principal) || (this instanceof Dashboard_Principal) ){
	 			 ApplicationController.GOPROFILE=false;
	 		}
	 		else{finish();
	 		}
	 		
	 	}
	 	
	 	//--Managing EditText with voice
	 	if (ApplicationController.EditTextVoice!=-1 && 
	 			!(ApplicationController.filterWord.equalsIgnoreCase("")) )
	 	{
	 		EditText et=(EditText) findViewById(ApplicationController.EditTextVoice);
	 		et.setText(ApplicationController.filterWord);
	 		ApplicationController.EditTextVoice=-1;
	 		ApplicationController.filterWord="";
	 	}
		Log.d(tag, "In the onResume() event");
	}

	/** Called when other activity comes in front. */
	@Override
	public void onPause() {
		super.onPause();
		Log.d(tag, "In the onPause() event");
	}

	/** Called when this activity is no longer visible. */
	@Override
	public void onStop() {
		super.onStop();
		Log.d(tag, "In the onStop() event");
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		ApplicationController.CLOSE();

		Log.d(tag, "In the onDestroy() event");
	}
	// --END Cycle life of
	// App-------------------------------------------------------

	public static OnTouchListener VoiceListener = new OnTouchListener() {
		
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			if(v instanceof EditText)
			{
				ApplicationController.EditTextVoice=v.getId();
				return true;
			} 
			return false;
		}
	};
}